package org.examcity.util.beanconverter;

import java.util.ArrayList;
import java.util.List;

/**
 * Class that represents a convertion mapping between two classes, including their fields.
 * 
 * @author Antonio Gomes
 */
public class Rule {

	private String name;
	private Class<?> classA;
	private Class<?> classB;
	private List<Field> fields = new ArrayList<Field>();

	private Converter converter;
	private Factory factory;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Factory getFactory() {
		return factory;
	}

	public void setFactory(Factory factory) {
		this.factory = factory;
	}

	public void setClassA(Class<?> fromClass) {
		this.classA = fromClass;
	}

	public void setClassB(Class<?> toClass) {
		this.classB = toClass;
	}

	public List<Field> getFields() {
		return fields;
	}

	public Class<?> getClassA() {
		return classA;
	}

	public Class<?> getClassB() {
		return classB;
	}

	public void setConverter(Converter beanConverter) {
		this.converter = beanConverter;
	}

	public Converter getConverter() {
		return converter;
	}

	/**
	 * Class that represents a field mapping.
	 * @author Antonio Gomes
	 */
	public static class Field {

		private String fieldA;
		private String fieldB;

		private Converter converter;

		public String getFieldA() {
			return fieldA;
		}

		public void setFieldA(String fromField) {
			this.fieldA = fromField;
		}

		public String getFieldB() {
			return fieldB;
		}

		public void setFieldB(String toField) {
			this.fieldB = toField;
		}

		public void setConverter(Converter cnverter) {
			this.converter = cnverter;
		}

		public Converter getConverter() {
			return converter;
		}

	}

}
